package com.pan;


import com.github.kwhat.jnativehook.GlobalScreen;
import com.pan.base.ReflectUtil;
import com.pan.config.ApplicationConfig;
import com.pan.listen.EventListener;
import com.pan.listen.hook.NativeListener;

public class Application {
    public static void main(String[] args) {
        String eventListenerName = ApplicationConfig.INSTANCE.getEventListenerName();
        EventListener eventListener = ReflectUtil.INSTANCE.newInstance(eventListenerName);
        try {
            GlobalScreen.registerNativeHook();
        } catch (Exception e) {
            System.err.println("There was a problem registering the native hook.");
            System.err.println(e.getMessage());
            System.exit(1);
        }
        NativeListener nativeListener = new NativeListener(eventListener);
        GlobalScreen.addNativeKeyListener(nativeListener);
    }
}